cmake_minimum_required(VERSION 3.15)
project(test_package CXX)

find_package(stdgpu CONFIG REQUIRED)

if (stdgpu_VERSION_STRING EQUAL "1.3.0")
    set(CMAKE_CXX_STANDARD 14)
else()
    set(CMAKE_CXX_STANDARD 17)
endif()

if (STDGPU_BACKEND STREQUAL "cuda")
    cmake_minimum_required(VERSION 3.17 FATAL_ERROR)
    enable_language(CUDA)
    add_executable(${PROJECT_NAME}_cuda test_package_cuda.cu)
    target_link_libraries(${PROJECT_NAME}_cuda stdgpu::stdgpu)
    set_target_properties(${PROJECT_NAME}_cuda PROPERTIES CUDA_ARCHITECTURES OFF)
endif()
if (STDGPU_BACKEND STREQUAL "hip")
    cmake_minimum_required(VERSION 3.21 FATAL_ERROR)
    enable_language(HIP)
    add_executable(${PROJECT_NAME}_hip test_package_hip.hip)
    target_link_libraries(${PROJECT_NAME}_hip stdgpu::stdgpu)
    set_target_properties(${PROJECT_NAME}_hip PROPERTIES HIP_ARCHITECTURES OFF)
endif()
if (STDGPU_BACKEND STREQUAL "openmp")
    add_executable(${PROJECT_NAME}_openmp test_package_openmp.cpp)
    target_link_libraries(${PROJECT_NAME}_openmp stdgpu::stdgpu)
endif()

if (NOT stdgpu_VERSION_STRING STREQUAL "1.3.0")
    # v1.3.0 does not have stdgpu/device.h
    add_executable(${PROJECT_NAME}_basic test_package_basic.cpp)
    target_link_libraries(${PROJECT_NAME}_basic stdgpu::stdgpu)
endif()
